package com.thrd.taiexhibition.adapter;

import android.content.Context;
import android.text.TextUtils;
import android.view.View;
import android.widget.FrameLayout;
import android.widget.TextView;

import com.facebook.drawee.generic.RoundingParams;
import com.thrd.basicframework.bean.BaseRecyclerAdapter;
import com.thrd.basicframework.utils.DensityUtil;
import com.thrd.taiexhibition.R;
import com.thrd.taiexhibition.bean.BeanCooperation;
import com.thrd.taiexhibition.fresco.FrescoImage;
import com.thrd.taiexhibition.fresco.FrescoUtils;

import java.util.List;

/**
 * 社会合作
 * @author: ${唐杰}
 * @date: 2021/3/31
 */
public class SocietyAdapter extends BaseRecyclerAdapter<BeanCooperation> {
    public SocietyAdapter(Context context, List<BeanCooperation> data) {
        super(context, data);
    }

    @Override
    public void bindData(BaseViewHolder holder, BeanCooperation beanCooperation) {
        FrescoImage mImage= (FrescoImage) holder.getView(R.id.fl_image);
        FrameLayout mCodeLayout= (FrameLayout) holder.getView(R.id.fl_code_layout);
        FrescoImage mCodeImage= (FrescoImage) holder.getView(R.id.fl_code_image);
        TextView mName = (TextView) holder.getView(R.id.tv_name);
        TextView mTime = (TextView) holder.getView(R.id.tv_time);

        FrescoUtils.getInstance().setPrefixProgressLoad(getContext(),mImage,beanCooperation.getCompanyDetailBannerImg(), RoundingParams.fromCornersRadius(DensityUtil.dip2px(getContext(),3)));
        mCodeLayout.setVisibility(beanCooperation.isCodeShow()? View.VISIBLE:View.GONE);
        FrescoUtils.getInstance().setPrefixProgressLoad(getContext(),mCodeImage,beanCooperation.getCompanyDetailQrCode(),RoundingParams.fromCornersRadius(DensityUtil.dip2px(getContext(),2)));
        if("0".equals(beanCooperation.getCompanyDetailType())){
            mName.setText("人才招聘");
        }else if("1".equals(beanCooperation.getCompanyDetailType())){
            mName.setText("联系我们");
        }else if("2".equals(beanCooperation.getCompanyDetailType())){
            mName.setText("新代理商申请");
        }
        mTime.setText(TextUtils.isEmpty(beanCooperation.getCreateTime())?"":beanCooperation.getCreateTime());
    }

    @Override
    public int getItemLayoutId() {
        return R.layout.item_society;
    }
}
